package com.genius.unite_platform.device.controller;

import com.alibaba.fastjson.JSONObject;
import com.genius.adminmanager.menu.entity.MenuJson;
import com.genius.adminmanager.other.entity.ResponseJson;
import com.genius.unite_platform.device.service.DeviceService;
import com.genius.workflow.log.ControllerLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class DeviceSelectController {
	@Autowired
    @Qualifier("DeviceSelectService")
    private DeviceService DeviceSelectService;
    /**
     * 跳转到列表页面
     * @param session
     * @return
     * @throws Exception
     */
    @GetMapping("/device/toSelect")
    public String toIndex(){
        return "/views/unite_platform/device/select";
    }
    
    @GetMapping("/device/getSelectHead")
    @ResponseBody
    public JSONObject getSelectHead(HttpSession session){
        JSONObject response = new JSONObject();
        response.put(ResponseJson.code, 0);
        JSONObject json = new JSONObject();
        json.put(MenuJson.menuId, "1d80522327984adcbae955b90465ca9b");
        response = DeviceSelectService.getSelectHead(json, session, response);
        return response;
    }
    /**
     * 查询数据
     * @return
     * @throws Exception
     */
    @ControllerLog(description="查看陈列设备数据")
    @PostMapping("/device/getSelectBody")
    @ResponseBody
    public JSONObject getSelectBody(@RequestBody JSONObject json){
        JSONObject response = new JSONObject();
        response.put(ResponseJson.code, 0);
        response = DeviceSelectService.getSelectBody(json, response);
        return response;
    }
}

